# CMake lowest version requirement
cmake_minimum_required(VERSION 3.14)

project(PLUGIN_CUSTOM_OPERATION)

# Compile options
add_compile_options(-std=c++17)
if(DEFINED ENV{CXX_ABI})
    add_definitions(-D_GLIBCXX_USE_CXX11_ABI=$ENV{CXX_ABI})
else()
    add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()

# 设置ASCEND_PATH（CANN包目录）和INCLUDE_BASE_DIR（头文件目录）
if(NOT "$ENV{ASCEND_CUSTOM_PATH}" STREQUAL "")      
    set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
else()
    set(ASCEND_PATH $ENV{ASCEND_HOME_PATH}/aarch64-linux)
endif()
set(ATB_PATH $ENV{ATB_HOME_PATH})
set(INCLUDE_BASE_DIR "${ASCEND_PATH}/include")

include_directories(
    ${INCLUDE_BASE_DIR}
    ${INCLUDE_BASE_DIR}/aclnn
    ${ATB_PATH}/include
    ${CMAKE_CURRENT_SOURCE_DIR})

link_directories(
    ${ATB_PATH}/lib/
    ${ASCEND_PATH}/lib64/
    ${CMAKE_SOURCE_DIR}/../out/
    )

file(GLOB_RECURSE atb_plugin_custom_operations_SRCS ./*.cpp)
add_library(plugin_custom_op SHARED ${atb_plugin_custom_operations_SRCS})

target_link_libraries(plugin_custom_op PRIVATE atb ascendcl libascendc_kernels.so)